import { S } from '../s';
import { IPSApplication } from '../app/ipsapplication';
import { IPSAppDEUIAction } from '../app/dataentity/ipsapp-deuiaction';
import { IPSAppDEUILogic } from '../app/dataentity/ipsapp-deuilogic';
import { IPSAppDataEntity } from '../app/dataentity/ipsapp-data-entity';
import { IPSAppUILogic } from '../app/logic/ipsapp-uilogic';
import { IPSAppViewEngine } from '../app/view/ipsapp-view-engine';
import { IPSAppViewLogic } from '../app/view/ipsapp-view-logic';
import { IPSControlLogic } from './ipscontrol-logic';
import { PSModelObjectImpl } from '../psmodel-object-impl';

export class PSControlLogicProxy
  extends PSModelObjectImpl
  implements IPSControlLogic
{
  get attrName(): string {
    return this.M.attrName;
  }

  get eventArg(): string {
    return this.M.eventArg;
  }

  get eventArg2(): string {
    return this.M.eventArg2;
  }

  get eventNames(): string {
    return this.M.eventNames;
  }

  get itemName(): string {
    return this.M.itemName;
  }

  get logicTag(): string {
    return this.M.logicTag;
  }

  get logicType():
    | 'APPDEUILOGIC'
    | 'APPDEUIACTION'
    | 'APPUILOGIC'
    | 'APPVIEWLOGIC'
    | 'APPVIEWENGINE'
    | 'PFPLUGIN'
    | 'SCRIPT'
    | 'DEUILOGIC'
    | 'DEUIACTION'
    | 'SYSVIEWLOGIC' {
    return this.M.logicType;
  }

  get name(): string {
    return this.M.name;
  }

  protected psappdeuiaction: IPSAppDEUIAction;
  getPSAppDEUIAction(): IPSAppDEUIAction | null {
    return (
      this.psappdeuiaction ||
      (this.psappdeuiaction = this.fillObjectModel(
        S._286,
        this.M.getPSAppDEUIAction,
        S._3f2,
      ) as IPSAppDEUIAction)
    );
  }

  protected psappdeuilogic: IPSAppDEUILogic;
  getPSAppDEUILogic(): IPSAppDEUILogic | null {
    if (this.psappdeuilogic != null) return this.psappdeuilogic;
    const value = this.M.getPSAppDEUILogic;
    if (value == null) {
      return;
    }
    const ipsappdataentity = this.getPSAppDataEntity();
    if (ipsappdataentity != null) {
      this.psappdeuilogic = ipsappdataentity.findPSAppDEUILogic(value);
    }
    return this.psappdeuilogic;
  }

  protected psappdataentity: IPSAppDataEntity;
  getPSAppDataEntity(): IPSAppDataEntity | null {
    return (
      this.psappdataentity ||
      (this.psappdataentity = this.fillObjectModel(
        S._f,
        this.M.getPSAppDataEntity,
        S._2aa,
      ) as IPSAppDataEntity)
    );
  }

  protected psappuilogic: IPSAppUILogic;
  getPSAppUILogic(): IPSAppUILogic | null {
    if (this.psappuilogic != null) return this.psappuilogic;
    const value = this.M.getPSAppUILogic;
    if (value == null) {
      return;
    }
    const ipsapplication = this.getParentPSModelObject(
      S._26e,
    ) as IPSApplication;
    if (ipsapplication != null) {
      this.psappuilogic = ipsapplication.findPSAppUILogic(value);
    }
    return this.psappuilogic;
  }

  protected psappviewengine: IPSAppViewEngine;
  getPSAppViewEngine(): IPSAppViewEngine | null {
    return (
      this.psappviewengine ||
      (this.psappviewengine = this.fillObjectModel(
        S._296,
        this.M.getPSAppViewEngine,
        S._2d8,
      ) as IPSAppViewEngine)
    );
  }

  protected psappviewlogic: IPSAppViewLogic;
  getPSAppViewLogic(): IPSAppViewLogic | null {
    return (
      this.psappviewlogic ||
      (this.psappviewlogic = this.fillObjectModel(
        S._82,
        this.M.getPSAppViewLogic,
        S._2d9,
      ) as IPSAppViewLogic)
    );
  }

  get scriptCode(): string {
    return this.M.scriptCode;
  }

  get timer(): number {
    return this.M.timer != null ? this.M.timer : 0;
  }

  get triggerType():
    | 'TIMER'
    | 'CTRLEVENT'
    | 'ITEMVISIBLE'
    | 'ITEMENABLE'
    | 'ITEMBLANK'
    | 'ATTRIBUTE'
    | 'CUSTOM'
    | 'VUE_DIRECTIVE' {
    return this.M.triggerType || 'CTRLEVENT';
  }
  get cls(): string {
    return 'PSControlLogicProxy';
  }
  instanceof(cls: string): boolean {
    if (cls == S._38d) return true;
    return super.instanceof(cls);
  }
}
